home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / applic / ntp / acts.arc / NBSTIME.DES < prev    next >
Encoding:
Text File  |  1988-10-14  |  62.7 KB  |  1,049 lines

  1.                         NATIONAL BUREAU OF STANDARDS
  2.  
  3.                               EXAMPLE SOFTWARE
  4.                                 FOR USING THE
  5.                    AUTOMATED COMPUTER TIME SERVICE (ACTS)
  6.  
  7. Program Name: NBSTIME
  8.  
  9. Usage: NBSTIME [ -d ]
  10.  
  11.      This program is used to set or check the date and time on an IBM personal
  12. computer (or equivalent) using data obtained by dialing the NBS using a Hayes-
  13. compatible modem connected to the computer via one of the COM ports. It can
  14. also be used to provide an output pulse on the line-printer port once per
  15. second to synchronize other devices.
  16.      <*2> Other versions of this program have been developed for performing
  17. the same functions on other hardware.  These variants are described in more
  18. detail in Appendix A.
  19.      The different operating modes are selected by means of a configuration
  20. file.  A separate program called MAKCFG (described in more detail below) can
  21. be used to make this file based on your answers to a series of questions. You
  22. may also generate or modify this file using any text editor.  Once the
  23. configuration file is prepared, you start the program by typing the command
  24. NBSTIME <return> in response to the system prompt.
  25.     The switch -d on the command line is optional.  If present, it specifies
  26. debug mode, and causes various intermediate parameters to be written to the
  27. screen.  The default is no debug mode.  The brackets enclosing the -d are
  28. meant to signify that the switch is optional.  They are never entered on the
  29. command line.
  30.   See the section below on operating instructions for more information.
  31.  
  32.                            The Configuration File
  33.  
  34.     The name of the configuration file is nbstime.cfg.  It must be located in
  35. the same directory from which the program will be run.  The configuration file
  36. may be prepared with a text editor such as EDLIN.  Alternatively, it may be
  37. generated using program MAKCFG, described below.  
  38. <*1>     The file contains 5 or 6 lines in the following format:
  39.  
  40.      Line 1: Dialing mode and telephone number.  The first character on line 1
  41. must be P, T or M.  P means that the modem will dial the telephone number
  42. using pulse mode (which emulates a rotary dial mechanism), T is for tone mode
  43. (which emulates push-button telephones) and M is for manual dialing (which
  44. means that the telephone connection will be completed manually outside of the
  45. program).  In pulse mode or tone mode, the remaining characters on the line
  46. are the digits 0 - 9, a space or a comma.  (Some modems will also accept the *
  47. and # symbols as part of the telephone number in tone mode and will dial them
  48. as well).  The telephone number is not modified by the program and the entire
  49. string is passed to the modem.  This line must contain the complete telephone
  50. number including long-distance access and area code (if necessary) and any
  51. other accounting digits as needed.  A comma signifies a pause for 2 seconds to
  52. wait for another dial tone, and spaces may be inserted to improve legibility. 
  53. For example:  T 9, 987 6 5 4 3 means dial 9, wait 2 seconds and then dial the
  54. remaining digits.  All digits are dialed in tone mode.  The telephone number
  55. must be less than 30 characters long including embedded blanks.  If the first
  56. character is M, then manual dialing is specified and the remainder of the line
  57. is ignored.  The program will prompt you to dial the telephone manually and
  58. will wait until you indicate that the connection is completed.
  59.  
  60. <*1> Line 2: The first character specifies which communication port will be
  61. used.  There are two versions of the program which differ in which ports they
  62. can use (see below for more details).  If the version that uses direct calls
  63. to the BIOS is used (called NBSTIMEB.EXE on the distribution disk), the first
  64. character must be 1 or 2 to specify communication via COM1 port or COM2 port,
  65. respectively, since only these ports are supported by the internal BIOS
  66. routines.  If the version that controls the ports directly is used (called
  67. NBSTIMED.EXE on the distribution disk), the first character may also be 3 or 4
  68. to specify ports COM3 or COM4, or it may be h (or H) to signify that the COM
  69. port will be specified by its hardware address on line 6 (see below).  This
  70. character must be set to match the port to be used.  
  71.      The second character on the line may be B (or b) or E (or e).  This
  72. character specifies whether the program is to expect responses to various
  73. dialing commands from the modem.  E specifies echo mode:  the program expects
  74. that characters sent to the modem in command mode will be echoed and that the
  75. modem will respond OK to a command; B specifies blind operation.  Some modems
  76. can be configured either way either by a switch or the Q command.  (A modem
  77. configured by the Q command will revert to the switch default upon reset.)  If
  78. the second character on the line is neither B nor E, then E is set by default. 
  79. Note that when the program is configured for echo mode (by specifying E
  80. explicitly or by default) then it will insist on responses and will abort if
  81. they are not received.  
  82.     The third character on the line specifies the communication speed (and,
  83. implicitly, the communication protocol).  If the third character is h (or H),
  84. then 1200-bits/s high-speed communication is selected using the 212A-type
  85. protocol.  If l (or L) is used, then 300-bits/s low-speed service is selected
  86. using 103-type protocol.  Many modems are capable of operating at either
  87. protocol (such dual-speed modems are often identified as "300-1200" type) and
  88. will switch to the correct speed and protocol automatically when then are
  89. activated.  Triple-speed modems of the "300-1200-2400" type may also be used
  90. at either 300 or 1200 bits/s.
  91.      Different messages are transmitted depending on the speed selected.  The
  92. message transmitted at 1200-bits/s contains the full date and time, including
  93. the Daylight-Savings Time flag and other information.  This service is
  94. intended for users who want to set or check the time of the computer clock
  95. with an uncertainty on the order of 10 - 20 milliseconds (0.01 s - 0.02 s)
  96. limited by the resolution and accuracy of the internal computer clock.  See
  97. the discussion below for more information.
  98.      The message transmitted at 300-bits/s is shorter because of the slower
  99. transmission speed, and contains only the time and the estimated line delay in
  100. milliseconds.  Therefore, it is not possible to set the computer clock since
  101. neither the date nor the correction for Daylight Savings Time are transmitted
  102. (the conversion to local time in the United States, for example, will change
  103. the date about 30% of the time, and the correction for Daylight Savings Time
  104. is necessary about 50% of the time.  It would be possible to assume that the
  105. computer date is correct, but the program does not do so.).  This service is
  106. intended for users who are more interested in the timing pulse capability (to
  107. be described below) or who design special-purpose systems that can make use of
  108. the full capability of the transmissions.
  109.      The fourth character on this line selects a timing-pulse capability. If
  110. this character is y (or Y), then a negative-going pulse (from +5 v to 0 v) is
  111. sent to the strobe line of the line-printer port (LPT1) every second upon
  112. receipt of the on-time marker (the * or # symbol at the end of each
  113. transmitted line) from NBS.  The pulse is sent to pin 1 of the DB25 female
  114. connector used for the standard line-printer interface.  Pin 25 of the same
  115. connector is at ground potential.  The leading-edge of the pulse is delayed
  116. from receipt of the on-time marker by a time on the order of micro-seconds,
  117. depending on the speed of the computer.  The pulse is approximately 20 micro-
  118. seconds wide.  This pulse is normally used by the printer interface software
  119. to transfer a character from the computer to the line printer (-strobe), so
  120. that the printer should be disconnected if this capability is enabled.
  121. <*1> There are three types of commonly used line-printer interfaces.  One of
  122. them is part of a combined monochrome display and printer adapter.  The second
  123. is just a printer adapter and the third is a combined serial/parallel adapter
  124. that is normally found only on AT-type machines.  The command register address
  125. for the first type is 3be (hex), while the second types both use 37a (hex). 
  126. If the strobe capability is enabled, the program obtains the address of the
  127. adapter from address 410 (hex) in low memory. (Note that address 410 hex is
  128. offset 0 in paragraph 41 hex).  If location 410 (hex) is zero or if the
  129. adapter does not  respond to a test pulse, the program will print a diagnostic
  130. message to that effect, the pulsing capability will be disabled and the
  131. program continues.
  132.      The fifth character on the line determines whether or not the received
  133. data will be used to set the computer clocks or merely to check them.  If this
  134. character is s (or S), then the clocks are set and then verified by comparing
  135. the time read from the internal clocks with the next line received from the
  136. NBS (both the received time and the internal clocks will have advanced by one
  137. second between the time they were set and when they were checked).  This mode
  138. does not preserve the time of the clocks before they were set and does not
  139. provide any information on the performance of the clocks.  If this character
  140. is d (or D) then the clocks are only compared.  The NBS time, the computer
  141. time and their difference are typed on the screen.  This mode preserves the
  142. time of the clock (since it is not set), and can also be used to give an
  143. estimate of the rate error (how much the computer clock is gaining or losing
  144. with respect to NBS).  The rate error (expressed in seconds per day, for
  145. example) is simply the time difference in seconds reported by the program
  146. divided by the number of days since the clock was last set.  This mode of
  147. operation is intended for users who want to characterize the performance of
  148. their clocks by observing their accuracy over extended periods of time.
  149.     The effect of this switch also depends on the AT switch (described below). 
  150. An IBM AT-type machine has two clocks -- one whose time is stored in the
  151. volatile memory and which is updated by the ROM BIOS only when the computer is
  152. turned on and one which is powered by a battery and which runs continuously. 
  153. Other models (such as the XT-class machines) do not have a battery clock. 
  154. This switch enables or disables the setting of BOTH clocks for an AT-class
  155. machine and only the memory-based clock for other models.  That is, both
  156. clocks are either set and verified or just compared.
  157.  <*2> The sixth character on the line is used to enable storing time-
  158. difference measurements in a file for subsequent more detailed analysis.  If
  159. this character is a, the time difference between the computer clocks and the
  160. NBS is stored in a file named NBSTIME.DIF.  The program writes the current
  161. time difference to the end of the file (if it currently exists) or creates a
  162. new file if it does not.  The time difference is written in the form: year,
  163. month, day, hour, minute, second, difference of volatile memory clock and
  164. difference of battery clock (if it exists).  The year, month, etc. are taken
  165. from the NBS transmission and the difference is a signed number which is
  166. positive if the computer clock is fast and negative if it is slow.  The
  167. difference is followed by a single letter giving the units: d, h, m, s for
  168. days, hours, minutes and seconds respectively.  This computation is separate
  169. from the setting or checking modes described above.  It is performed when the
  170. fifth line is received from NBS, so that the difference will be written to the
  171. file BEFORE the clocks are set (if that option is specified).  Although the
  172. action of this switch is independent of whether the clocks are set, the
  173. interpretation of the data is not.  If the fifth character specifies that the
  174. clocks shall always be set, then the difference written to the file by this
  175. operation is the time error that has accumulated since the last NBS access,
  176. since the clocks were corrected at that time.  If the fifth character
  177. specifies that the clocks are not to be set, however, then the time error is
  178. the cumulative error since the clocks were last set, and the error since the
  179. last NBS access is the difference between the current and previous values for
  180. the differences.
  181.  <*2> If this character is A, then in addition to writing the current
  182. differences to file NBSTIME.DIF as described above, the program will compare
  183. the current differences against the values that were estimated the previous
  184. time (i.e. the values found at the end of the file when the program was first
  185. activated). The previous differences are subtracted from the current
  186. estimates, and the results are divided by the time that has elapsed since the
  187. last value was stored in the file.  The result is an estimate of the rate of
  188. the computer clock with respect to NBS.  These rate estimates are printed on
  189. the terminal in units of seconds per day, where a positive value means that
  190. the computer clock is running faster than the NBS rate.  The uncertainty of
  191. this rate estimate is discussed below.
  192.   <*2> If this character is n (or N), then the time difference is not stored
  193. in the archive file and the rate estimate is not computed.  Note that this is
  194. the only parameter whose effect is different in upper or lower case. 
  195.      The remainder of this line is ignored and may contain any characters.
  196.  
  197.      Line 3:  This line specifies the time zone of the user.  This parameter
  198. is used to convert the time transmitted by the NBS from universal time to
  199. local time.  The parameter represents the value of local time minus Universal
  200. time in hours.  Locations West of Greenwich are negative, while those East are
  201. positive.  If specified by value, the value should not exceed 12 hours, but
  202. this is not checked.  The zone may be specified by name or numerically as
  203. follows:
  204.  
  205. First character on line      Action            Offset in hours
  206.  
  207. P or p                       U. S. Pacific Time    -8
  208.  
  209. M or m                       U. S. Mountain Time   -7
  210.  
  211. C or c                       U. S. Central Time    -6
  212.  
  213. E or e                       U. S. Eastern Time    -5
  214.  
  215. Z or z                       Greenwich Time         0
  216.  
  217. + or - or digits             Number read            defined by number
  218.  
  219. In all cases, the remainder of the line is ignored.  Thus the following lines
  220. are equivalent:
  221.  
  222. Mountain Standard Time
  223. m
  224. -7     The Rocky Mountains are here
  225.  
  226. The program does not support conversion to local time in half-hour zones (i.e.
  227. zones where the time difference between local time and Universal time is not
  228. an integral number of hours).
  229. <*1> Program MAKCFG (see below) also allows the user to specify any time zone
  230. by its letter.  If that method is used, MAKCFG converts the letter to its
  231. equivalent numerical offset.  See MAKCFG for more details.
  232.  
  233.      Line 4.  If the first character is 1, then the user observes Daylight
  234. Savings Time, and the local time will be adjusted accordingly if necessary,
  235. based on the Daylight Savings Time flag transmitted by NBS.  If the first
  236. character is 0, the Daylight Savings Time flag is ignored and no such
  237. adjustment will be made.  No other characters are permitted on this line.
  238. If you use a 1 here, then the time will be advanced by one hour if the NBS
  239. transmission indicates that Daylight Savings Time is currently in effect.
  240. You will need to use 0 if you live in an area that does not observe Daylight
  241. Savings Time at all (such as Arizona), or if you change to Daylight Time on a
  242. different day from the national standard.
  243.  
  244.      Line 5.  This is called the AT-flag.  If the first character is 1, the
  245. user has an AT-type machine with a CMOS battery clock, and the program will
  246. set or check it (in addition to the clock that is stored in memory).  If the
  247. first character is 0, the CMOS clock is neither set nor checked.  Zero is
  248. appropriate for users who do not have a CMOS battery clock or who have this
  249. type of equipment but do not want it to be used. Note that the time stored in
  250. the volatile memory clock is lost when the power is removed, so that you
  251. should probably set and check the battery clock if you have it.  The remainder
  252. of this line is ignored and may contain any characters.
  253.  
  254. <*1>  Line 6.  This line is optional.  It is only necessary if you are using
  255. the direct-access version of the program (NBSTIMED on the distribution) and if
  256. the first character on line 2 is h (or H), indicating that the COM port is to
  257. specified in terms of its hardware address.  In that case, the hardware
  258. address must appear on this line beginning in column 1.  The address must be
  259. specified in hex and is usually three digits long.  The usual values for COM1
  260. and COM2 are 3f8 and 2f8, respectively.  This specification is not necessary
  261. if you use standard COM1 or COM2 ports, since the addresses of those ports can
  262. always be obtained by the program.  It is also not necessary if you use COM3
  263. or COM4, and if the addresses of these ports are stored in the BIOS data
  264. tables (at addresses 0:404 and 0:406, respectively).  Although these locations
  265. are reserved for the addresses of COM3 and COM4, many versions of the BIOS do
  266. not use them.  If this is the case in your system, then the program will halt
  267. with the message, "Port not in configuration" if you try to use specify COM3
  268. or COM4  using a 3 or a 4 as the first character on line 2.  In that case you
  269. must place an 'h' in col 1 of line 2 and you can then specify the hardware
  270. address here.  The hardware address can usually be obtained from the
  271. installation manual provided by hardware manufacturer.  Typical values for
  272. COM3 and COM4 are 3e8 and 2e8, respectively, but other values may be used on
  273. your system.
  274.  
  275.                             Hardware Requirements
  276.  
  277.      The program will run on an IBM computer or equivalent.  The computer must
  278. contain at least one serial port configured as a standard COM port with an
  279. external modem compatible with the Bell System 212A standard (1200 bits/s) or
  280. the 103 standard (300 bits/s) and capable of responding to the Hayes dialing
  281. commands.  Internal modems and multiple speed modems that emulate these
  282. configuration are acceptable.
  283.  
  284.      If the output pulse capability is selected, the computer must have a
  285. parallel output port for a line-printer that is configured as LPT1.  The
  286. address of the port can be either 37a (hex) or 3be (hex).  The former is used
  287. by the printer adapter and the combined serial/parallel adapter, while the
  288. latter is used for the printer portion of the combined monochrome
  289. display/printer adapter.  If this capability is enabled, the printer should be
  290. turned off or disconnected from the computer before the program is started. 
  291.  
  292.                             Software Requirements
  293.  
  294. <*1> Program NBSTIMEB uses calls to the standard IBM DOS and BIOS routines
  295. except for the output pulse option that directly accesses the parallel output
  296. port.  This version is isolated from the vagaries of the hardware by the BIOS,
  297. and it is likely to work with non-standard hardware that emulates the IBM
  298. standard using a custom BIOS.  It can only use ports COM1 or COM2, however,
  299. since those are the only ports supported by the standard BIOS routines.  It
  300. also requires that the modem assert the Clear-to-Send line (CTS) before the
  301. connection is made.  Again, that is a requirement of the standard BIOS. 
  302. Program NBSTIMED uses calls to the IBM DOS and BIOS routines to set and read
  303. the clocks, but input and output are performed by direct commands to the
  304. hardware ports.  This version of the program can access all four COM ports and
  305. does not require that the modem assert CTS, but its operation depends on the
  306. detailed hardware configuration and is therefore less likely to work with
  307. third-party equipment that does not emulate the IBM personal computer at the
  308. hardware level.  Both versions are written entirely in Borland Turbo C under
  309. DOS 3.2 (with no assembly language code), but are likely to work under earlier
  310. versions of DOS back to 2.0.  Either version can be generated by altering a
  311. constant in the configuration file NBSTIME.H (supplied with the source code)
  312. and then recompiling the affected modules (see below).
  313.  
  314.                              Transmission Format
  315.  
  316.      When the telephone connection to the NBS time service is completed, the
  317. NBS hardware sends timing information at either 300 bits/s or 1200 bits/s
  318. using standard ASCII characters.  A line of information is sent every second,
  319. and the transmission continues for a predetermined number of seconds after
  320. which the connection is automatically broken.  The two transmission speeds use
  321. different formats.
  322.       In the high-speed (1200 bits/s) service, each line begins with a five-
  323. digit integer giving the Modified Julian Day Number (which advances by 1 every
  324. day and is about 47000 in 1988), and the year, month, day, hour, minute and
  325. second in Universal (Greenwich) Time.  This time will be correct upon receipt
  326. of the terminating character (* or #) to be described below.
  327.      The next parameter is the Daylight Savings Time flag.  Values from 50 to
  328. 1 indicate the Daylight Savings Time is currently in effect; other values (99
  329. to 51 and 0) indicate that Standard Time is currently in effect.  Values other
  330. than 50 or 0 indicate both the current time and the number of days left before
  331. a transition to the other time is needed.
  332.      Next is the leap-second flag.  Zero is the normal case.  A value of 1
  333. indicates that an extra second will be added following 23:59:59 (Universal
  334. Time) on the last day of the current month.  This second will be called
  335. 23:59:60, and the second after it will be 00:00:00 of the next day.  A value
  336. of 2 indicates that a second is to be dropped on the last day of the current
  337. month.  The second following 23:59:58 will be 00:00:00 of the next day.  Leap
  338. seconds are usually required about every 18 months and are most commonly added
  339. at the end of June or December.  It is unlikely that the dropping of a second
  340. will be necessary in the near future. Note that the leap second transition is
  341. linked to Universal Time, unlike the Daylight Savings transition which is
  342. linked to local time.
  343.      The next number is the estimated offset between UT1 (a time scale derived
  344. from the rotation of the earth) and UTC (a time scale derived from frequency
  345. standards).  The units are in seconds in steps of 0.1 second. 
  346.      The next parameter is the estimated telephone-line time delay in
  347. milliseconds as determined by the NBS hardware.  It is estimated as one-half
  348. of the average time it takes the terminating character to be sent to the user
  349. and returned. (Any user who intends to make use of this delay must echo the
  350. terminating character back using either hardware or software methods.  If the
  351. terminator is not echoed back to NBS, a nominal delay is assumed.)   The
  352. remaining characters on the line are UTC(NBS) and the terminating character.  
  353.     The terminating character will be a * if the delay has not yet been
  354. measured or is not stable, and will change to a # if 4 consecutive
  355. measurements yield consistent values.  The NBS hardware uses the time delay
  356. estimated in this way to transmit the subsequent terminating character so that
  357. it will arrive on time at the user.  If the user does not echo the terminator
  358. back to NBS, then a nominal delay is assumed and the terminator is sent using
  359. this nominal value.  This nominal value is unlikely to be in error by more
  360. than 0.1 second unless the circuit is transmitted via satellite.
  361.  
  362.                            Operating Instructions
  363.  
  364.      The program may be run from any directory on any disk.  If necessary,
  365. copy the files nbstimed.exe (or nbstimeb.exe) and nbstime.cfg to the
  366. appropriate directory.  If you will use program makcfg, then copy makcfg.exe
  367. to the same directory.  Make that directory the default using the cd command. 
  368. Edit the configuration file nbstime.cfg if necessary (or run program MAKCFG). 
  369. Any text editor, such as EDLIN may be used for this purpose.  (Word processing
  370. programs can also be used to edit the file provided that the output file is in
  371. standard DOS format.  Note that this is not the default output format for most
  372. word processors.)
  373.      When the files are ready, connect the modem to the telephone line and to
  374. the computer and execute the program.  If the program is to be run from
  375. directory blah on disk c, for example:
  376.  
  377. copy nbstime*.*    c:\blah                copy the files.
  378. copy makcfg.exe  c:\blah
  379.  
  380. c:                                      change to c disk if necessary
  381.  
  382. cd \blah                                set directory if necessary
  383.  
  384. type nbstime.cfg                        type the configuration file on the
  385.                                         screen to see if it needs to be       
  386.                                         modified.  If it does, you may do     
  387.                                         so using an editor such as edlin,     
  388.                                         as shown below.  Or, you may run      
  389.                                         program MAKCFG, described below       
  390.                                         to produce a new nbstime.cfg file.    
  391.  
  392. edlin nbstime.cfg
  393.    .
  394.    .
  395.    .                                     edit configuration file if necessary
  396.  
  397. ex                                       exit from the editor
  398.  
  399. rename nbstimed.exe nbstime.exe          rename either version as nbstime
  400.  
  401. or    
  402.  
  403. rename nbstimeb.exe nbstime.exe
  404.  
  405. nbstime                                  run program
  406.  
  407.                              Operating Sequence
  408.  
  409.      This is what happens when the program is run:
  410.  
  411. 1. The command line is examined to see if it contains -d.  If it does, then
  412. set the debug mode to 1 (turn it on); otherwise leave debug at 0.  This
  413. parameter is used for testing the program and should not normally be
  414. specified.
  415.  
  416. 2.  Read the configuration file nbstime.cfg and set the various parameters. 
  417. If an error is detected in reading the file, print a message and stop.  If the
  418. configuration file does not exist in the default directory, then use a default
  419. configuration which is identical to the sample configuration file.
  420.  
  421. 3.  Initialize the com port to 300 or 1200 bits/s, no parity, 1 stop bit.  If
  422. output pulses are requested, determine the address of the parallel printer
  423. port.  If the address cannot be determined then print a diagnostic message and
  424. disable the output pulse selection.
  425.  
  426. 4.  Dial the number if necessary.  If remote modem answers print connect
  427. message and proceed.  If no answer or busy then print message and stop.  If
  428. manual dialing was specified, print a message for manual dialing and wait for
  429. connection.
  430.  
  431. 5.  Read the first 6 lines and echo the terminating character back to NBS for
  432. measuring the transmission line delay.  Send an output pulse when each
  433. terminating character is received if that capability was specified in the
  434. configuration file.  Print these lines on the screen.  The terminating
  435. character will be * initially and will change to # if the NBS hardware
  436. measures a stable transmission delay.  If 300-bits/s service was specified,
  437. continue reading lines in this manner until the NBS breaks the connection;
  438. then hang up the local modem and exit.
  439.  
  440. <*2> 6. If 1200 bits/s service and archive mode are specified, the time
  441. difference between the computer clocks and the NBS transmission is computed
  442. when the fifth line is received and stored in file NBSTIME.DIF.  If a rate
  443. estimate was also requested, subtract the current values from the values that
  444. were at the end of file NBSTIME.DIF and divide the results by the time that
  445. has elapsed since the last communication.  Convert the result to seconds per
  446. day.
  447.  
  448. <*1> 7.  If 1200-bits/s service is specified, then use the time of the 7th and
  449. 8th lines to set the computer clock (if setting was enabled).  The time is set
  450. to the received time of the 8th line provided that it is exactly 1 second
  451. later than the time received in the 7th line.  If the times of the two lines
  452. do not differ by exactly one second, then try again with the next two lines. 
  453. This method minimizes the probability that the computer clocks will be set
  454. incorrectly as a result of a transmission error.  If the AT flag is on, then
  455. both the memory clock and the CMOS battery clock are set.  Adjust the time to
  456. local time and for daylight savings time as specified in the configuration
  457. file.  Echo the terminator of this line back to NBS and send an output pulse
  458. if pulse selection is enabled.
  459.  
  460. 8.  Read the time of the next line received from NBS and compare the time with
  461. the current values of the computer clocks.  (All of the clocks should have
  462. advanced by 1 second.)  Print both the times and the time difference values on
  463. the screen.  If the AT flag in the configuration file is set, then compare
  464. both clocks with the time received from NBS and print both sets of times and
  465. time differences on the screen.  The memory-based clock "ticks" 18.2 times per
  466. second, while the CMOS battery clock in an AT-type computer "ticks" once per
  467. second.  It is not possible to read or set either clock to better than one of
  468. its ticks, so that differences of one tick or less are not significant. (This
  469. is discussed in more detail below.)
  470.  
  471. 9.  If output pulses are not enabled, then hang up the modem and exit.  If
  472. automatic dialing was selected, a % character is sent to NBS and the Hayes
  473. hang-up sequence is sent to the local modem.  If manual dialing was selected,
  474. then the local modem is presumed to not understand the Hayes commands and the
  475. Hayes hang-up sequence is not sent.  If output pulses are enabled then do not
  476. hang-up the telephone, but continue receiving lines as in paragraph 5 above
  477. until the NBS disconnects the call.
  478.  
  479.                                Timing Accuracy
  480.  
  481.      The volatile memory clock in personal computers of this type (IBM-pc or
  482. equivalent) ticks approximately 18.2 times/second (about every 56
  483. milliseconds), and the time is kept as the number of ticks past midnight.  It
  484. is not possible to alter the tick fraction using calls to either DOS or the
  485. ROM BIOS.  This has two significant consequences:
  486.  
  487. 1. Since there are not an integral number of ticks/second, not all times can
  488. exist.  For example, 00:00:01.00 is not an integral number of ticks after
  489. midnight and therefore can not be set and will never be read.  The nearest
  490. times are 00:00:00.98 and 00:00:01.04.  The average offset between any given
  491. time and the nearest time that can be set is 0.5 ticks or about 28
  492. milliseconds.
  493.  
  494. 2. Time intervals are also uncertain by up to 1 tick since the tick fraction
  495. when the time is read cannot be known to the program.  Again, the average
  496. offset is 0.5 ticks (28 milliseconds).
  497.  
  498.     The CMOS clock in AT computers cannot be set to better than a second since
  499. it does not store fractions of a second.  The seconds fraction must therefore
  500. be truncated or rounded when the CMOS clock is addressed.  This will further
  501. limit the accuracy of the time following a re-boot of the system (since the
  502. CMOS clock is copied into the system RAM clock at that time).  
  503.  
  504.      In addition to these errors in setting and reading the clock in this type
  505. of computer, there is a possible error in the computation of the telephone
  506. line delay.  This delay is measured at the NBS as one-half of the time it
  507. takes the terminating character (* or #) to be sent from NBS to the distant
  508. computer and return to the NBS hardware.  This method depends on the
  509. assumption that the transit time is reciprocal, i.e. that the time from NBS to
  510. the computer is the same as from the computer to NBS.  This may not be true if
  511. the two paths are different;  many 1200 bits/s modems also have delays that
  512. are not reciprocal.  Modem delays vary from brand to brand and are on the
  513. order of tens of milliseconds.   
  514.  
  515.      The accuracy of the computer clocks after they have been set is
  516. determined by the accuracy of the rate of the internal crystal-controlled
  517. oscillators.  These rates are usually sensitive to temperature and other
  518. factors and are unlikely to be stable to better than about 1 part-per-million
  519. (about 0.1 seconds/day), so that errors in the time of this order are likely
  520. even if the time is set exactly initially.
  521.  
  522.     There may also be a problem with the date if the machine is run
  523. continuously, since the date in some computers is not advanced when the time
  524. passes through midnight.  (This comment applies to the clock stored in memory
  525. only.  The CMOS clock in AT-type machines advances the date properly, but this
  526. clock is only used to set the time initially when the computer is started.) 
  527. This is a "feature" of the BIOS routines that manage the memory-based clock.
  528.  
  529.      The accuracy of the output pulse is limited primarily by the stability of
  530. the telephone line delay, since the delays within the computer are likely to
  531. be very small by comparison.  Many modems contain equalizing circuits that
  532. attempt to measure the characteristics of the telephone line to which they are
  533. connected.  The operation of these circuits may adversely affect the stability
  534. of the measured time delay.  Although the measured delay may be quite stable
  535. from second to second (with fluctuations of less than 50 micro-seconds), it
  536. often changes significantly every few seconds (as much as 500 micro-seconds)
  537. as the equalizing circuits operate.  The equalizing circuits are usually more
  538. important at the higher speeds so that this effect is likely to be smaller at
  539. 300 bits/s.
  540.  
  541.    <*2>  The method used by the program to estimate the rate of the computer
  542. clocks may produce estimates that have large uncertainties if the program is
  543. run very often.  The rate is computed by subtracting the current time
  544. difference from the previously estimated value and the result will be affected
  545. by the jitter in both estimates.  The uncertainty of the result will be about
  546. 40% higher than the uncertainty of either of its constituent differences. 
  547. This second difference (the difference of the differences) will have an
  548. average uncertainty of about 1.4 X 0.5 ticks or about 40 milliseconds (= 0.040
  549. seconds).  If the two program runs are 5 minutes (= 0.00347 day) apart, an
  550. uncertainty in the second differnce of 40 milliseconds translates into a rate
  551. uncertainty of 0.040/0.00347 = 11.5 seconds/day.  This uncertainty is likely
  552. to be much larger than the true rate error of the clock so that a rate
  553. estimate done this way is unlikely to give an accurate estimate of the
  554. performance of the computer clock.  If, on the other hand, the two program
  555. runs are 5 hours apart (= 0.21 day), the same uncertainty in the second
  556. difference translates into a rate uncertainty of 0.040/0.21 = 0.2 seconds/day. 
  557. Thus, estimating the rate more often than 1 or 2 times per day is not
  558. recommended.
  559.  
  560.    <*2> A second difficulty with the rate-estimating process will occur if the
  561. program is configured to set the computer clocks.  The time difference is
  562. written to the archive file BEFORE the clocks are set (see above).  When the
  563. clocks are set, however, the time difference is set to zero, but a subsequent
  564. rate estimate does not take this into account and uses the last value found in
  565. the file even though it has been invalidated by the process of setting the
  566. clocks.  Thus both the archiving process and the rate estimating process yield
  567. unambiguous values only if the clocks are not set.
  568.  
  569.                                Fixing Problems
  570.  
  571.      If the program does not work, the following suggestions may be helpful.  
  572.  
  573. 1.  First check the hardware configuration to be sure that it is connected, is
  574. in working order and is an IBM personal computer or functional equivalent. 
  575. Likewise be sure that the modem is connected to the computer and to the
  576. telephone line and that it responds to the Hayes protocol.
  577.  
  578. <*1> 2.  Many modems have a small loudspeaker that is connected to the
  579. telephone line until the connection is made.  Some modems also have lights to
  580. show the status of the call.  The modem should start dialing within a few
  581. seconds after the program is initiated.  If a loudspeaker is present, the dial
  582. tone should be heard followed by the dialing sequence.  If lights are present,
  583. OH (off-hook) should light and SD and RD (send-data and receive data) should
  584. flash.  If none of these things happens, be sure that the hardware is properly
  585. configured and that the configuration file specifies the correct port.  If you
  586. are using NBSTIMEB, which uses the BIOS for input/output, it is possible that
  587. the dialing commands are not being sent to the modem.  The IBM BIOS checks for
  588. various status indicators from the modem and will not initiate a transmission
  589. to the modem unless these status indicators are correct.  In particular, DSR
  590. (Data Set Ready) must be true.  In some modems this line follows DCD (Data
  591. Carrier Detect) and therefore will not be true until the telephone connection
  592. has been completed (this is logical for a modem used to answer incoming calls,
  593. but not for modems that can originate calls since they should be "ready" to
  594. accept a dialing command before the call is established).  In this case, the
  595. modem will never be sent dialing instructions, since it will appear not ready
  596. at the start of the program.  This may usually be changed by a switch in the
  597. modem.  When set appropriately, this switch forces DSR and DCD to be true
  598. continuously.  This adjustment is described in the instruction manual for the
  599. modem.  It is often implemented as switch number 6.  Note that changing the
  600. setting of this switch may change the operation of other programs, especially
  601. some terminal emulators that access the COM ports directly and not via the
  602. BIOS commands.  In particular, Data Carrier Detect is normally used to
  603. indicate that the modem is receiving a signal from a distant modem over the
  604. telephone connection, and if this signal is forced to be continuously true,
  605. some terminal emulators may refuse to dial the modem, assuming that the
  606. connection is already established.  NBSTIMED does not use the BIOS and is not
  607. limited in this way.
  608.  
  609. 3.  The error message, "No response from modem." means that the modem did not
  610. respond to the dialing sequence as expected.  The message is followed by a
  611. number indicating how far into the sequence the error was sensed.  Number 1
  612. signifies no response to the initial command to reset the modem (ATZ).  If
  613. this message is received, be sure that the hardware is okay and that the modem
  614. is connected to the COM port specified in the configuration file.  Numbers 2
  615. through 4 indicate no response to various parts of the set-up sequence.  If
  616. this occurs, be sure that the echo/blind parameter on the second line of the
  617. configuration file is set appropriately and edit the configuration file (or
  618. rerun program MAKCFG) if necessary.  A response of 5 is probably a telephone
  619. line problem -- since modem problems are likely to have resulted in a failure
  620. at an earlier stage in the process.  These problems can usually be diagnosed
  621. by listening to the progress of the call on the built-in loudspeaker, if
  622. possible.  Be sure that the telephone number is correct and that any long-
  623. distance codes have been entered correctly. If a pause for a second dial-tone
  624. has been inserted, be sure that it is long enough, and add extra pause
  625. commands (,) if necessary.
  626.  
  627. 4.  If the connection is established, but the time is not set correctly,
  628. verify that the lines printed on the screen show the correct date and time. 
  629. If 1200-bits/s service is selected, the first number on each line is the
  630. Modified Julian Day (MJD) Number, which advances by 1 every day and is about
  631. 47000 in 1988.  It is not used by the program.  The next numbers are year,
  632. month, day, hour, minute and second in order, where the hour is in Universal
  633. Time (UTC), followed by the Daylight Savings flag, which is an integer from 0
  634. to 99.  The remainder of the line is not used by the program.   If 300-bits/s
  635. service is selected, each line contains the time, the estimated line delay in
  636. milliseconds and the terminating character that is used for synchronization. 
  637. As discussed above, the time is not set in this mode, so that only the
  638. presence of the terminating character is significant.  If the lines are
  639. partially garbled then either the telephone line or the modem should be
  640. suspected.  If the lines are totally garbled, it is likely that the modem
  641. cannot communicate at the selected speed or does not conform to the
  642. corresponding standard.  It is also possible that there is a problem with the
  643. receive portion of the COM port, although this is less likely since the
  644. dialing commands use the same hardware.
  645.  
  646. 5.  If only the CMOS clock is not set correctly (using 1200 bits/s service),
  647. verify that it conforms to the IBM standard and that the configuration file is
  648. set correctly.
  649.  
  650. 6.  If you select output pulses on the line-printer port (LPT1), be sure that
  651. the line printer is not connected and that only pins 1 and 25 on the printer
  652. interface connector are connected to the external device that uses the pulses
  653. (the pulse appears on pin 1, and pin 25 is ground).  If the line-printer is
  654. left connected and on-line, then each output pulse will send a random
  655. character to the printer.  The printer will respond to these transmissions in
  656. unpredictable ways, and subsequent print operations may not work properly as a
  657. result.  It may be necessary to re-boot the system in this case.
  658.  
  659.  
  660.                                Error Handling
  661.  
  662.      The program deals with only certain types of errors:  Syntax errors in
  663. the configuration file are likely to be detected, although the program does
  664. not place any limits on the telephone number, and an error in specifying it is
  665. unlikely to be sensed until the modem responds erratically.  Hardware problems
  666. or inconsistencies between the hardware and the configuration file will also
  667. be sensed since they will most likely result in no response from the modem or
  668. in a protocol error.
  669.  
  670.      The most likely source of error in a nominally healthy and properly
  671. configured system is a transmission error.  We can distinguish several
  672. different types of problem depending on where the error occurs.
  673.  
  674.      1.  The line terminating character (* or #) is garbled or lost.  The
  675. program will not detect the end of the line and will concatenate the line with
  676. the following one.  If output pulses are enabled, no pulse will be sent.  If
  677. the line in error is the line that is used either for setting the clock or
  678. checking it, then an error of 1 second will occur either in setting the clock
  679. or in comparing it.  If this is not either of those lines then the program
  680. will simply continue with no error (the other lines are displayed but are not
  681. used in any other way).  Since the length of the line is known, this error
  682. could be detected in principle, but the current version of the program does
  683. not do so.
  684.  
  685.      2.  Another character on the line is converted to the terminator (* or
  686. #).  The program will detect a premature end-of-line and synchronization with
  687. the NBS will likely be affected.  If output pulses are enabled, a pulse will
  688. be sent at the wrong time.  The error introduced in setting the clock depends
  689. on which line this occurs in just as in 1 above.  Note that this error is
  690. rather unlikely since there are 128 characters that an error might produce,
  691. but only 2 of them are legal terminators.  This error could also be detected
  692. in principle by a line-length check as above, but the current version of the
  693. program does not do so.
  694.  
  695. <*1>  3.  A digit of the time is transformed into another character that is
  696. not a digit.  This could be detected in principle by carefully checking each
  697. character on the line, but the current version of the program does not do so.
  698. If the line in error is used neither to set the time nor to check it, then the
  699. error will have no effect.  The computer clock is not set until two
  700. consecutive lines whose times differ by exactly one second are received, so
  701. that two identical transmission errors must occur at the same place in two
  702. consecutive lines for the clocks to be set incorrectly.  This is unlikely, but
  703. not impossible.  If this is the line that is used to check the clock then the
  704. discrepancy between the local time and the NBS time is likely to be large,
  705. since the error is unlikely to be confined to the least significant digit of
  706. the seconds.  If output pulses are enabled, this type of error has no effect
  707. on them since they are governed only by the receipt of the terminating
  708. character.
  709.  
  710. <*1>  4.  A digit of the time is transformed into another legal digit.  This
  711. error cannot be detected by examining the line.  The probability is rather
  712. small, however, since there are only 10 legal digits out of 128 possibilities. 
  713. As with 3 above, if this is the line that is used to check the time, the
  714. discrepancy between the local time and the NBS time is likely to be large
  715. since the transmission error is unlikely to be confined to the least
  716. significant digit of the seconds.  As in 3 above, there is no degradation of
  717. the output pulse timing.
  718.  
  719.      Errors 3 and 4 could also be dealt with by assuming some previous
  720. knowledge of the time or date and rejecting values that deviated from this
  721. assumed date and time by too great an amount.  Illegal month and day
  722. combinations could also be detected in this way.
  723.  
  724. <*1>    The probability that these errors will result in setting the time
  725. incorrectly has been minimized by insisting that the times of two consecutive
  726. transmissions differ by exactly one second.  A general version of such a
  727. scheme is quite complex since it must cope with all of the peculiarities of
  728. the calendar, and only a simplified version has been implemented.  The seconds
  729. value from the first line of the pair is decoded and examined.  If it is
  730. greater than 57, then the comparison is postponed, since the following second
  731. may be the first second of a new minute. (Second number 58 is the last second
  732. of the current minute if a negative leap-second is imminent, second number 59
  733. is usually the last second of the current minute and second number 60 will be
  734. the last second if a positive leap-second is imminent.)  If the current second
  735. is less than 57, the seconds digits are converted to blanks and the remainder
  736. of the date and time are stored in a buffer as received.  When the next line
  737. is received, the seconds value is extracted and tested for equality with the
  738. previous value +1.  If this comparison succeeds, the remaining digits of the
  739. date and time (with the seconds field converted to blanks in both cases) are
  740. compared character by character (all characters must be the same). If either
  741. comparison fails a transmission error is assumed, and the process is begun
  742. again with the next two lines since the program has no way of knowing which of
  743. the two lines is in error.  This process continues until two consecutive lines
  744. are decoded and are found to be consecutive or until the NBS hardware hangs up
  745. the telephone. 
  746.  
  747. Name: MAKCFG
  748.  
  749. Usage: MAKCFG
  750.  
  751.     This program constructs a file named NBSTIME.CFG based on the answers to a
  752. series of questions.  The program may be run from any directory of any disk,
  753. but is most conveniently run from the same directory in which program NBSTIME
  754. is located.
  755.  
  756.      The number of each question refers to the line of the output file that is
  757. being assembled.  Thus questions 1a, 1b, ... are used to assemble the various
  758. parameters for the first line.  The contents of each line are described in the
  759. description for the NBSTIME program.
  760.  
  761.      All of the acceptable responses for each question are listed as part of
  762. question.  Alphabetic answers may be given in upper or lower case.  All
  763. answers must be terminated with a carriage return (or enter), and this fact is
  764. denoted by the symbol <return> in the description for each response.  If you
  765. respond to any question with ? <return>, additional information will be
  766. printed out and the question will be repeated.  If your response is not one of
  767. the expected responses, the message, "I don't understand ..." is printed and
  768. the question is repeated.  
  769.  
  770.      Your response is not passed to the program until the <return> key is
  771. pressed, so that errors may be erased using the delete key as usual and the
  772. corrected response may then be entered.  If the expected response is a single
  773. letter or digit, then all characters after the first one on the line are
  774. ignored (and an error will occur if the first character is not one of the
  775. expected responses even if a subsequent character is okay).  Thus if when
  776. either
  777.  
  778.           y <return>
  779. or
  780.           n <return>
  781.  
  782. is expected, you enter either
  783.  
  784.           y <return>
  785. or
  786.           yes, we have no bananas <return>,
  787.  
  788. the two responses will be treated identically since only the first character
  789. is parsed and the remainder of the line is discarded. (Note that the "no" in
  790. the middle of the second response is ignored since only the first character is
  791. examined.)
  792.  
  793.      This program checks to see if a configuration file already exists in your
  794. directory.  If it finds the file, it will print a message and give you the
  795. choice of renaming the old file, over-writing the old file or stopping to
  796. think about it. 
  797.  
  798.      If you choose to rename the file, the existing file will be renamed
  799. CONFIG.OLD immediately, and a new file named NBSTIME.CFG will be created.  The
  800. renaming process will fail if a file named CONFIG.OLD already existed in the
  801. current directory, and the program will give up if that happens.  You must
  802. then erase one of the configuration files or copy them to another directory or
  803. sub-directory so that the program won't find them.  If the renaming operation
  804. succeeds, a new file named NBSTIME.CFG is then created.
  805.  
  806.      If you choose to over-write the existing configuration file or if the
  807. configuration file did not previously exist, a new file named NBSTIME.CFG is
  808. created in the current directory (with zero length).
  809.  
  810. <*1>   The program then asks which version of the program you are planning to
  811. use.  If you select the BIOS version of the program, then only COM1 or COM2
  812. can be used for communication; COM3 and COM4 can also be used if you select
  813. the direct-access version, and question 2a, which requests this information is
  814. modified accordingly.  If you select the direct access version and if your
  815. response to the port specification is 'h' then an additional question asking
  816. for the hardware address of the port is also asked.
  817.  
  818. <*2>  It is also possible to generate configuration files for the other
  819. versions of the program using program MAKCFG.  A question at the start asks
  820. you which version of NBSTIME you are using.  The differences among the various
  821. configuration files are discussed in Appendix A.
  822.  
  823.      The various configuration parameters are not written to the file until
  824. all of the questions have been answered, and an empty file named NBSTIME.CFG
  825. will be left in your directory if the program does not run to completion. 
  826. This might happen, for example, if you responded to any question with a
  827. control-c (pressing control key and c key together), since such a response
  828. will cause the program to stop immediately.  
  829.  
  830. <*1>  Program MAKCFG allows you to specify your time zone by its letter.  To
  831. use this capability, you should respond with a * when you are asked for your
  832. time zone.  The program will then ask you to specify your time zone by letter. 
  833. You may respond in either upper or lower case.  Your answer is converted to a
  834. numerical offset according to the following table and the numerical offset is
  835. then stored in the file.  Note that you cannot enter these letters in the
  836. configuration file directly, since NBSTIME does not recognize them (except for
  837. Z).  
  838.  
  839.   Response       Difference (hours)       Response       Difference(hours)
  840.                  Local - Universal                       Local - Universal
  841.      A                +1                     N                -1
  842.      B                +2                     O                -2   
  843.      C                +3                     P                -3
  844.      D                +4                     Q                -4
  845.      E                +5                     R                -5
  846.      F                +6                     S                -6
  847.      G                +7                     T                -7
  848.      H                +8                     U                -8
  849.      I                +9                     V                -9
  850.      K                +10                    W                -10
  851.      L                +11                    X                -11
  852.      M                +12                    Y                -12
  853.  
  854.      Z                0
  855.  
  856.      Note that the letter J is not assigned and that the zone centered on the
  857. prime meridian is assigned the letter Z.  The zone centered on the
  858. international date line has two assignments (M and Y), which will yield the
  859. same time on different days; most of the inhabited areas in that zone are on
  860. the Western side of the date line and will therefore use M.
  861.                             Notes about Revisions
  862.  
  863.      Paragraphs marked with a <*> have been revised since the original edition
  864. of the documentation as follows:
  865.  
  866. Original release      26 February 1988
  867.  
  868. <*1>                  15 July 1988
  869.  
  870. <*2>                  30 September 1988
  871.  
  872.      The modifications to the software are described below:
  873.  
  874. Original release      26 February 1988
  875.  
  876. First Modification    31 May 1988
  877.  
  878.      This modification corrected an error in the conversion to local time. 
  879. The error occurred if daylight savings time was in effect, if the conversion
  880. to daylight savings time was specified in the configuration file and if the
  881. program was run between 12:00:00 midnight and 12:59:59 am local daylight
  882. savings time.  The conversion to local daylight savings time should advance
  883. the date in this case, since the corresponding standard times would be
  884. 11:00:00 pm and 11:59:59 pm on the previous day, but the program did not do
  885. this.  This error does not occur at other times during the day or if daylight
  886. savings time is not in effect or is not enabled in the configuration file
  887. NBSTIME.CFG.  The transition days at the beginning and end of daylight savings
  888. time were also handled correctly.
  889.      The problem results from the interaction between the conversion to local
  890. standard time and the additional conversion for daylight savings time on the
  891. transition days at the beginning and end of the daylight savings time period. 
  892. Since the transition occurs at 02:00:00 am local time, the conversion for
  893. daylight savings time on a transition day must be delayed until after the
  894. local time and date have been computed.  On any other day or after 11:00:00 pm
  895. on a transition day, however, the conversion to daylight savings time may
  896. advance the date, and must therefore be performed before the local date can be
  897. known.
  898.      We have modified the software so that conversions on transition days and
  899. on other days are handled separately.
  900.  
  901. Second modification   15 July 1988
  902.  
  903.      The second modification provides for several enhancements:
  904.  
  905. 1.  Two versions of the program are now supported: NBSTIMEB and NBSTIMED.  The
  906. _B version uses the BIOS for input/output and the _D version accesses the
  907. hardware ports directly.  The two versions can be produced from the same
  908. source files by editing the file NBSTIME.H (see comments in that module) and
  909. then recompiling the affected routines.  The table below shows all of the
  910. modules comprised in both versions of NBSTIME.  Modules that are affected by a
  911. change in NBSTIME.H are indicated by (nbstime.h) on the same line.  Comments
  912. in each module describe the dependence.  In some cases (such as dial.c and
  913. hangup.c), the difference is primarily in the values for constants that set
  914. the time-out delays, since program NBSTIMED is considerably faster than
  915. NBSTIMEB.
  916.  
  917. 2.  The program does not set the time of the computer clock unless two
  918. consecutive lines have times that differ by exactly one second.  This is
  919. intended to prevent the time from being set erroneously as a result of a
  920. transmission error.
  921.  
  922. 3.  The telephone line status report in module dial.c has been modified.  The
  923. previous version assumed that a modem response to a dial command was the final
  924. status of the call, and that a response containing an 'R' was produced either
  925. by NO ANSWER or NO CARRIER and was therefore reported an incomplete call. 
  926. Some modems were found to send an intermediate status of RINGING.  This
  927. version of the program differentiates between R as the first letter of the
  928. word and ER at the end.  In the first case, an intermediate response is
  929. assumed and the program waits for a second message.  In the second case an
  930. incomplete call is assumed and the program exits.
  931.  
  932. Third modification -- 30 September 1988
  933.  
  934. The third modification consisted of the following changes:
  935.  
  936. 1.  This modification adds code to estimate the rate offset of the computer
  937. clock with respect to NBS.  This is done by subtracting the difference between
  938. the computer clock and the NBS with the corresponding values read from the
  939. last line of the archive file.  The second differences are normalized by the
  940. time that has elapsed between the two estimates.  The result is converted to
  941. seconds per day and is printed on the terminal following the time difference.
  942. If the machine has a both a RAM and a CMOS clocks, then the rates of both
  943. clocks will be estimated.
  944.  
  945. 2.  Additional code has been added to enable the program to run on different
  946. computers.  The additional code is activated by editing file nbstime.h (see
  947. the comments in that file for more details). The capabilities of the different
  948. versions are described in Appendix A.
  949.      The following table lists all of the modules, their functions and their
  950. last revision.  File nbstime.h is included in all of the modules, and the
  951. parameters defined in it govern the compilation.
  952.  
  953. Module      Depends     Last         Function of
  954. Name          on      modified         Module
  955.  
  956. nbstime.h               #3       Defines parameters that control compilation
  957. rdline.c  (nbstime.h)   #3       Main program
  958. wrtbuf.c  (nbstime.h)   #3       Write string of characters to port.
  959. rdbuf.c   (nbstime.h)   #3       Read string of characters from port.
  960. inilin.c  (nbstime.h)   #3       Determine hardware addresses and initialize.
  961. dial.c    (nbstime.h)   #3       Dial telephone number and report status.
  962. wait.c    (nbstime.h)   #3       Delay for 1 second.
  963. hangup.c  (nbstime.h)   #3       Hang-up telephone line and reset modem.
  964. parset.c  (nbstime.h)   #3       Parse received line and set clocks.
  965. cnvbcd.c  (nbstime.h)   #3       Convert binary to packed BCD.
  966. setcfg.c  (nbstime.h)   #3       Read configuration file and set parameters.
  967. sndptr.c  (nbstime.h)   #3       Send pulse to line printer port.
  968. diftim.c  (nbstime.h)   #3       Compute and display time difference.
  969. unpbcd.c  (nbstime.h)   #3       Convert packed BCD to binary.
  970. arcdif.c  (nbstime.h)   #3       Compute time difference and write to file.
  971. cmplst.c  (nbstime.h)   #3       Compare times of consecutive lines.
  972. getlst.c  (nbstime.h)   #3       Gets last line of archive file and parses it.
  973. makefile                #3       input for make command on SUN system
  974. nbstime.prj             #3       input for make command on IBM PC system
  975.                                 Appendix A
  976.  
  977. 1.  The SUN version.  This version of the software was developed on a SUN
  978. workstation, but should work with only minor modifications in other UNIX
  979. environments.  Most UNIX environments keep time internally in units of seconds
  980. (and possibly fractions of a second) since 1 January 1970 Universal
  981. (Greenwich) Time.  The conversion to local date and time is performed by the
  982. operating system as needed.  
  983.      The sun version of NBSTIME converts the time received from NBS to seconds
  984. since 1 January 1970 by subtracting 40587 (the MJD of 1 January 1970) from the
  985. received MJD, multiplying the difference by the number of seconds in a day
  986. (86400) and then adding the number of seconds equal to the received time. 
  987. This result is used both for time comparisons and to set the computer clock,
  988. if necessary. 
  989.      In addition to the limitations discussed above (see the sections on
  990. Timing Accuracy and Error Handling), there are several other important
  991. considerations that are unique to this version.  Although any user may compare
  992. the computer time with NBS, setting the time on the computer is a privileged
  993. operation that requires super-user status.  The program will not complain
  994. about a request to set the time by a user who is not the super-user, but the
  995. operation will be rejected by the operating system.  In addition, changing the
  996. clock in a multi-user, multi-processing environment may adversely affect the
  997. operation of user tasks scheduled via "cron" and background real-time
  998. processes ("daemons").  In extreme cases, the causality that is necessary for
  999. the proper operation of commands such as "make" might be violated.  Finally,
  1000. the program may not echo the on-time marker promptly if the system is heavily
  1001. loaded or if the task is run through a window.
  1002.      The sun version of the software uses the same source code files as the
  1003. IBM PC version.  The header file nbstime.h must be edited to define the
  1004. constant SUN and to remove the definition of the constants IBMPC and BIOS. 
  1005. This process is described in the comments in file nbstime.h.  
  1006.  
  1007.                          The SUN Configuration File
  1008.  
  1009.      The configuration file for the sun system differs somewhat from the
  1010. version that is used by the IBMPC version.  The SUN version may be produced
  1011. with any text editor.  Program MAKCFG may also be used.
  1012.  
  1013. Line 1.  This line is used to specify the telephone number.  It is identical
  1014. to the IBM PC version.  See the discussion above for more details.
  1015.  
  1016. Line 2.  The first two characters specify the communication port.  There are
  1017. three different possibilities:
  1018.  
  1019.    a.  <a><b> specifies port /dev/tty<a><b>
  1020.  
  1021.    b.  <a> -  specifies port /dev/tty<a>
  1022.   
  1023.    c.   -     specifes that the port will be defined on line 3.
  1024.  
  1025. where <a> and <b> are two characters chosen from a - z or A - Z or 0 - 9. Note
  1026. that case is significant: AB specifies /dev/ttyAB whereas b- specifies
  1027. /dev/ttyb.  Note that if the first character is -, the second character is not
  1028. used and the characters specified below follow immediately starting in column
  1029. 2.
  1030.      The next characters on the line are:
  1031.  
  1032.      E/e/B/b           Echo/Blind dialing.  See description for IBM PC
  1033.      H/h/L/l           1200/300 speed.      See description for IBM PC
  1034.      S/s/D/d           Set/Check clock.     See description for IBM PC
  1035.      a/A/n/N           Archive and rate     See description for IBM PC
  1036.  
  1037. These characters must appear in the order shown with no embedded spaces.  All
  1038. of these parameters have the same effect as in the IBMPC version.  Note that
  1039. it is not possible to send a pulse to the line-printer port in the sun
  1040. version.
  1041.  
  1042. Line 3.  If the first character of line 2 was a -, then the path of the
  1043. communications port is specified here as a string of characters.  The string
  1044. will be passed directly to the operating system and is not checked or parsed. 
  1045. Thus instead of specifying <a> - at the start of line 2, you could equally
  1046. well put a - at the start of line 2 (followed by the other parameters as
  1047. appropriate) and put /dev/ttya on line 3.  If the port is fully specified on
  1048. line 2 then this line is not needed.
  1049.